package org.mtmi.io;

import org.mtmi.ui.controls.Control;
import org.mtmi.ui.controls.Keyboard;
import org.mtmi.ui.controls.Knob;
import org.mtmi.ui.controls.LedBargraph;
import org.mtmi.ui.controls.SKnob;
import org.mtmi.ui.controls.SSlider;
import org.mtmi.ui.controls.Slider;
import org.mtmi.ui.controls.Spinner;
import org.mtmi.ui.controls.TrackPad;
import org.mtmi.ui.controls.ValueTransformer;
import org.mtmi.ui.controls.midi.MidiController;
import org.mtmi.ui.controls.midi.MidiKeyboard;
import org.mtmi.ui.scenes.Scene;

/**
 * A registry for controls factories extension, also know how to create default controls.
 */
public class ControlFactory 
{
	public static Control create( Scene scene, int flags, String clazz )
	{
		String the_class = clazz.intern(); //I want to use '==' operator
		if( the_class == SSlider.class.getName() ) {
			return new SSlider( scene, flags );
		}
		if( the_class == SKnob.class.getName() ) {
			return new SKnob( scene, flags );
		}
		if( the_class == Knob.class.getName() ) {
			return new Knob( scene, flags );
		}
		if( the_class == Slider.class.getName() ) {
			return new Slider( scene, flags );
		}
		if( the_class == Spinner.class.getName() ) {
			return new Spinner( scene, flags );
		}
		if( the_class == ValueTransformer.class.getName() ) {
			return new ValueTransformer( scene, flags );
		}
		if( the_class == TrackPad.class.getName() ) {
			return new TrackPad( scene, flags );
		}
		if( the_class == LedBargraph.class.getName() ) {
			return new LedBargraph( scene, flags );
		}
		if( the_class == MidiController.class.getName() ) {
			return new MidiController( scene, flags );
		}
		if( the_class == Keyboard.class.getName() ) {
			return new Keyboard( scene, flags );
		}
		if( the_class == MidiKeyboard.class.getName() ) {
			return new MidiKeyboard( scene, flags );
		}
//TODO: insert any factory extension here....		
		return null;
	}
	
}
